package b.a.a;

import a.c.q;
import a.e.e;
import a.j.g;
import a.j.hc;
import a.j.pg;
import org.apache.batik.dom.GenericDOMImplementation;
import org.apache.batik.svggen.SVGGraphics2D;
import org.w3c.dom.*;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.awt.*;
import java.io.*;

public class b
  extends e
{
  private Document c;
  private SVGGraphics2D d;
  private d e;
  private pg f;
  private pg g;
  private boolean h = true;
  private boolean i = false;
  private Object j = b.a.d.d.c;
  public static boolean k;
  
  public String a()
  {
    return "SVG Format";
  }
  
  public String b()
  {
    return "svg";
  }
  
  public boolean c()
  {
    return false;
  }
  
  public void a(d paramd)
  {
    this.e = paramd;
  }
  
  public d f()
  {
    if (!k) {
      if (this.e != null) {
        this.e.a(this);
      }
    }
    return this.e;
  }
  
  public Object g()
  {
    return this.j;
  }
  
  public void a(Object paramObject)
  {
    boolean bool = k;
    if ((bool) || (b.a.d.d.b.isCompatibleValue(paramObject)))
    {
      if (paramObject != null)
      {
        this.j = paramObject;
        if (!bool) {}
      }
      else
      {
        this.j = b.a.d.d.e;
        if (!bool) {}
      }
    }
    else {
      throw new IllegalArgumentException("Incompatible SVG rendering hint value: " + paramObject);
    }
  }
  
  public boolean h()
  {
    return this.i;
  }
  
  public void a(boolean paramBoolean)
  {
    this.i = paramBoolean;
  }
  
  public pg i()
  {
    return this.g;
  }
  
  SVGGraphics2D j()
  {
    return this.d;
  }
  
  public void a(g paramg, InputStream paramInputStream)
    throws IOException
  {
    throw new UnsupportedOperationException("Can't read files in " + a());
  }
  
  public void a(g paramg, OutputStream paramOutputStream)
    throws IOException
  {
    boolean bool = k;
    this.d = new a_(l());
    this.d.getGeneratorContext().setComment("Generated by ySVG");
    this.d.setRenderingHint(b.a.d.d.b, this.j);
    this.d.setRenderingHint(b.a.c.b.a, new b.a.c.b());
    pg localpg = (pg)paramg.fb();
    this.g = localpg;
    if (!bool) {
      if (this.f != null)
      {
        this.g = this.f;
        this.g.b(paramg);
      }
    }
    if (!bool) {
      if (this.g == null) {
        this.g = a(paramg);
      }
    }
    Dimension localDimension = this.g.I();
    if (!bool) {
      if (n()) {
        this.d.setSVGCanvasSize(localDimension);
      }
    }
    hc localhc = this.g.W();
    if (!bool)
    {
      if (f() != null) {
        this.g.a(f());
      }
      if (!bool) {
        this.g.a(this.d);
      }
    }
    else if (f() != null)
    {
      this.g.a(localhc);
    }
    if (!bool) {
      if (localpg != null)
      {
        if (bool) {
          break label280;
        }
        if (this.g != this.f) {
          break label274;
        }
      }
    }
    if (!bool) {
      if (localpg != this.g) {
        paramg.c(this.g);
      }
    }
    if (localpg != null) {
      paramg.a(localpg);
    }
    label274:
    this.g = null;
    label280:
    a(this.d.getRoot(), new OutputStreamWriter(paramOutputStream, "UTF-8"), this.i);
    if (bool) {
      q.o = !q.o;
    }
  }
  
  void a(Element paramElement, Writer paramWriter, boolean paramBoolean)
    throws IOException
  {
    boolean bool = k;
    Node localNode1 = paramElement.getParentNode();
    Node localNode2 = paramElement.getNextSibling();
    label181:
    try
    {
      paramElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", "http://www.w3.org/2000/svg");
      paramElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", "http://www.w3.org/1999/xlink");
      DocumentFragment localDocumentFragment = paramElement.getOwnerDocument().createDocumentFragment();
      if (!bool)
      {
        localDocumentFragment.appendChild(paramElement);
        if (!paramBoolean) {}
      }
      else
      {
        f.a(localDocumentFragment, true);
      }
      if (!bool) {
        if (f() != null)
        {
          f().a(localDocumentFragment, paramWriter);
          if (!bool) {
            break label116;
          }
        }
      }
      a(localDocumentFragment, paramWriter);
      label116:
      paramWriter.flush();
    }
    finally
    {
      if ((bool) || (localNode1 != null))
      {
        if (!bool) {
          if (localNode2 == null)
          {
            localNode1.appendChild(paramElement);
            if (!bool) {
              break label181;
            }
          }
        }
        localNode1.insertBefore(paramElement, localNode2);
      }
    }
  }
  
  void a(Node paramNode, Writer paramWriter)
    throws IOException
  {
    try
    {
      DOMSource localDOMSource = new DOMSource(paramNode);
      StreamResult localStreamResult = new StreamResult(paramWriter);
      TransformerFactory localTransformerFactory = TransformerFactory.newInstance();
      try
      {
        localTransformerFactory.setAttribute("indent-number", new Integer(2));
      }
      catch (IllegalArgumentException localIllegalArgumentException) {}
      Transformer localTransformer = localTransformerFactory.newTransformer();
      localTransformer.setOutputProperty("indent", "yes");
      localTransformer.transform(localDOMSource, localStreamResult);
    }
    catch (TransformerConfigurationException localTransformerConfigurationException)
    {
      throw new IOException(localTransformerConfigurationException.getMessage());
    }
    catch (TransformerException localTransformerException)
    {
      throw new IOException(localTransformerException.getMessage());
    }
  }
  
  protected Document k()
  {
    DOMImplementation localDOMImplementation = GenericDOMImplementation.getDOMImplementation();
    return localDOMImplementation.createDocument(null, "svg", null);
  }
  
  public Document l()
  {
    if (!k) {
      if (this.c == null) {
        this.c = k();
      }
    }
    return this.c;
  }
  
  public pg a(g paramg)
  {
    boolean bool = k;
    pg localpg = new pg(paramg);
    Rectangle localRectangle = paramg.d();
    Dimension localDimension = new Dimension(localRectangle.width, localRectangle.height);
    localpg.setSize(localDimension);
    localpg.setPreferredSize(localDimension);
    localpg.c(localRectangle.x - 10, localRectangle.y - 10, localRectangle.width + 20, localRectangle.height + 20);
    localpg.c(0.0D);
    if (q.o) {
      k = !bool;
    }
    return localpg;
  }
  
  public void a(pg parampg)
  {
    this.f = parampg;
  }
  
  public pg m()
  {
    return this.f;
  }
  
  public boolean n()
  {
    return this.h;
  }
  
  public void b(boolean paramBoolean)
  {
    this.h = paramBoolean;
  }
  
  private static class a_
    extends SVGGraphics2D
  {
    a_(Document paramDocument)
    {
      super();
    }
    
    a_(a_ parama_)
    {
      super();
    }
    
    public Graphics create()
    {
      return new a_(this);
    }
    
    public void setRenderingHint(RenderingHints.Key paramKey, Object paramObject)
    {
      if ((b.k) || ((!RenderingHints.KEY_ANTIALIASING.equals(paramKey)) && (!RenderingHints.KEY_TEXT_ANTIALIASING.equals(paramKey)))) {
        super.setRenderingHint(paramKey, paramObject);
      }
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     b.a.a.b

 * JD-Core Version:    0.7.0.1

 */